import java.awt.Point;
import java.util.HashMap;
import java.util.Map;
import org.rsbot.script.methods.Bank;
import org.rsbot.script.methods.Calculations;
import org.rsbot.script.methods.Equipment;
import org.rsbot.script.methods.Inventory;
import org.rsbot.script.methods.NPCs;
import org.rsbot.script.methods.Objects;
import org.rsbot.script.util.Timer;
import org.rsbot.script.wrappers.RSNPC;
import org.rsbot.script.wrappers.RSObject;

final class VoluntaryThieve$Actions
{
  private final VoluntaryThieve.Actions.Methods methods = new VoluntaryThieve.Actions.Methods(this, null);
  private boolean hasGloves;
  private boolean isUsingGloves = true;
  private boolean isEquipmentChecked;
  private boolean hasThieved;
  private boolean isExtraCheckDone;
  private boolean isForcingBlackjack;
  private boolean isLured;
  private boolean isUnableToReach;
  private int currentTrainerId;
  private Timer stunnedTimer;
  private Point tileOffset;
  private final Map<Integer, Boolean> trainerInclusions = new HashMap();

  private VoluntaryThieve$Actions(VoluntaryThieve paramVoluntaryThieve)
  {
  }

  private VoluntaryThieve.Action getNext()
  {
    if (!VoluntaryThieve.Actions.Methods.access$2200(this.methods)) {
      return get(14, new Object[0]);
    }
    if ((!VoluntaryThieve.Options.access$900(VoluntaryThieve.access$800(this.this$0))) && (this.isUsingGloves)) {
      if (!this.isEquipmentChecked) {
        this.hasGloves = VoluntaryThieve.access$2300(this.this$0).containsAll(new int[] { 10075 });
        this.isEquipmentChecked = true;
      }

      if (!this.hasGloves) {
        if (VoluntaryThieve.access$2400(this.this$0).contains(10075)) {
          return get(13, new Object[0]);
        }
        if (VoluntaryThieve.Options.access$2500(VoluntaryThieve.access$800(this.this$0))) {
          this.currentTrainerId = 0;

          if ((!VoluntaryThieve.Actions.Methods.access$2600(this.methods)) && (!VoluntaryThieve.Actions.Methods.access$2700(this.methods))) {
            return VoluntaryThieve.Actions.Methods.access$2800(this.methods);
          }
          localObject = VoluntaryThieve.access$2900(this.this$0).getNearest(new int[] { 52397 });
          if (localObject == null) {
            return get(7, new Object[0]);
          }
          if (!((RSObject)localObject).isOnScreen()) {
            return VoluntaryThieve.access$3000(this.this$0).tileOnMap(((RSObject)localObject).getLocation()) ? get(6, new Object[0]) : get(7, new Object[0]);
          }

          return VoluntaryThieve.access$3100(this.this$0).isOpen() ? get(11, new Object[0]) : get(10, new Object[0]);
        }

        this.isUsingGloves = false;
        this.this$0.log("Won't be using any more gloves of silence.");
      }

    }

    if (VoluntaryThieve.Actions.Methods.access$3200(this.methods)) {
      this.currentTrainerId = 0;
      return get(12, new Object[0]);
    }

    if ((VoluntaryThieve.Actions.Methods.access$2600(this.methods)) && (!VoluntaryThieve.Actions.Methods.access$2700(this.methods))) {
      return VoluntaryThieve.Actions.Methods.access$2800(this.methods);
    }
    Object localObject = this.currentTrainerId != 0 ? new int[] { this.currentTrainerId } : VoluntaryThieve.Actions.Methods.access$3300(this.methods);

    if (localObject.length == 0) {
      return get(1, new Object[0]);
    }
    RSNPC localRSNPC = VoluntaryThieve.access$3400(this.this$0).getNearest(localObject);

    if (localRSNPC == null) {
      return get(1, new Object[0]);
    }
    if (this.isUnableToReach) {
      this.trainerInclusions.put(Integer.valueOf(localRSNPC.getID()), Boolean.valueOf(false));
      this.isUnableToReach = false;
      this.currentTrainerId = 0;
      return getNext();
    }

    if (!localRSNPC.isOnScreen()) {
      if (!this.isExtraCheckDone) {
        this.currentTrainerId = 0;
        this.isExtraCheckDone = true;
        return getNext();
      }

      this.isExtraCheckDone = false;
      return VoluntaryThieve.access$3500(this.this$0).tileOnMap(localRSNPC.getLocation()) ? get(0, new Object[] { localRSNPC }) : get(1, new Object[0]);
    }

    this.currentTrainerId = localRSNPC.getID();
    if ((VoluntaryThieve.Options.access$900(VoluntaryThieve.access$800(this.this$0))) && (localRSNPC.getAnimation() != 12413)) {
      if (!this.isForcingBlackjack) {
        if (VoluntaryThieve.Actions.Methods.access$3600(this.methods)) {
          this.isLured = false;
        }
        if (!this.isLured) return VoluntaryThieve.Actions.Methods.access$3700(this.methods) ? get(4, new Object[0]) : get(3, new Object[] { localRSNPC }); 
      }
      else {
        this.isForcingBlackjack = false;
      }
      return get(5, new Object[] { localRSNPC });
    }

    return (VoluntaryThieve.Action)get(2, new Object[] { localRSNPC });
  }

  private VoluntaryThieve.Action get(int paramInt, Object[] paramArrayOfObject)
    throws IllegalArgumentException
  {
    if ((0 > paramInt) || (paramInt >= 15)) {
      throw new IllegalArgumentException("Invalid action: " + paramInt);
    }
    if (paramInt == 0) {
      return new VoluntaryThieve.Actions.1(this, "Walking to trainer", 0, new long[] { this.this$0.random(1425, 1635), this.this$0.random(1645, 1850), this.this$0.random(4925, 5135) }, paramArrayOfObject);
    }

    if (paramInt == 2) {
      return new VoluntaryThieve.Actions.2(this, "Pickpocketing the trainer", 2, this.this$0.random(250, 1250), this.this$0.random(515, 725), paramArrayOfObject);
    }

    if (paramInt == 12) {
      return new VoluntaryThieve.Actions.3(this, "Waiting while being stunned", 12, 0L, this.this$0.random(4820, 5210));
    }

    if (paramInt == 13) {
      return new VoluntaryThieve.Actions.4(this, "Equipping a new pair of gloves", 13, this.this$0.random(2345, 2745), this.this$0.random(3215, 3445));
    }

    if (paramInt == 3) {
      return new VoluntaryThieve.Actions.5(this, "Luring the trainer", 3, this.this$0.random(250, 1250), this.this$0.random(1455, 2135), paramArrayOfObject);
    }

    if (paramInt == 4) {
      return new VoluntaryThieve.Actions.6(this, "Luring/talking to the trainer", 4, this.this$0.random(5550, 6750), this.this$0.random(3225, 4475));
    }

    if (paramInt == 5) {
      return new VoluntaryThieve.Actions.7(this, "Knocking the trainer", 5, this.this$0.random(250, 1250), this.this$0.random(2145, 2625), paramArrayOfObject);
    }

    if (paramInt == 9) {
      return new VoluntaryThieve.Actions.8(this, "Walking to the door", 9, new long[] { this.this$0.random(1245, 1485), this.this$0.random(2145, 2675), this.this$0.random(4595, 5780) });
    }

    if (paramInt == 8) {
      return new VoluntaryThieve.Actions.9(this, "Opening the door", 8, this.this$0.random(4525, 4895), this.this$0.random(2975, 3225));
    }

    if (paramInt == 6) {
      return new VoluntaryThieve.Actions.10(this, "Walking to the bank", 6, new long[] { this.this$0.random(1425, 1635), this.this$0.random(2345, 2755), this.this$0.random(5255, 5825) });
    }

    if (paramInt == 10) {
      return new VoluntaryThieve.Actions.11(this, "Opening the bank", 10, this.this$0.random(1425, 1625), this.this$0.random(2452, 2855));
    }

    if (paramInt == 11) {
      return new VoluntaryThieve.Actions.12(this, "Banking", 11, this.this$0.random(6445, 7125), this.this$0.random(2745, 3465));
    }

    if (paramInt == 7) {
      return new VoluntaryThieve.Actions.13(this, "Walking to the bank area", 7, new long[] { this.this$0.random(1245, 1475), this.this$0.random(2345, 2765), this.this$0.random(4985, 5375) });
    }

    if (paramInt == 1) {
      return new VoluntaryThieve.Actions.14(this, "Walking to the training area", 1, new long[] { this.this$0.random(1245, 1475), this.this$0.random(2345, 2765), this.this$0.random(4985, 5375) });
    }

    if (paramInt == 14) {
      return new VoluntaryThieve.Actions.15(this, "Failsafe timeout", 14, 0L, this.this$0.random(7200, 13250));
    }

    throw new AssertionError("Unsupported action: " + paramInt);
  }
}